<template>
    <div>
        <input type="text" ref="inputTextRef">
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';

let inputTextRef = ref(null);

onMounted(() => {
    // setup中获取不到dom，mounted就可以了
    console.log(inputTextRef.value);
})
</script>

<!-- <script>
import { onMounted, ref } from 'vue';

export default {
    setup() {
        let inputTextRef = ref(null);
        onMounted(() => {
            // setup中获取不到dom，mounted就可以了
            console.log(inputTextRef.value);
        })

        return { inputTextRef }
    }
}
</script> -->